
{include file="public/top" /}
<script src="__STATIC__echarts.min.js"></script>
<body class="layui-anim layui-anim-up">

<div class="x-body">
    <xblock>

        <div  style="line-height:40px">
            总访问量：<?php echo $params['total'];?>，
            今日访问量：<?php echo $params['day'];?>，
            昨日访问量：<?php echo $params['yesterday'];?>

            【本周访问量：<?php echo $params['week'];?>，
            上周访问量：<?php echo $params['last_week'];?>，
            对比上周访问：
            <?php if($params['contrast_week'] > 0):?>
            <span style="color: red;font-weight: bold">上升</span>
            <?php elseif($params['contrast_week'] == 0):?>
            <span style="color: #FFB800;font-weight: bold">持平</span>
            <?php else:?>
            <span style="color: #5FB878;font-weight: bold">下降</span>
            <?php endif;?>
            <?php echo $params['contrast_week'];?>%】
            【本月访问量：<?php echo $params['month'];?>，
            上月访问量：<?php echo $params['last_month'];?>，
            对比上月访问：
            <?php if($params['contrast_month'] > 0):?>
            <span style="color: red;font-weight: bold">上升</span>
            <?php elseif($params['contrast_month'] == 0):?>
            <span style="color: #FFB800;font-weight: bold">持平</span>
            <?php else:?>
            <span style="color: #5FB878;font-weight: bold">下降</span>
            <?php endif;?>
            <?php echo $params['contrast_month'];?>%】


        </div>

    </xblock>
    <div style="height: 40px;">
        <form class="layui-form layui-col-md12 x-so">
            <!--分开-->

            <button class="layui-btn layui-btn-danger " onclick="_getData(7)" type="button">最近7天</button>
            <button class="layui-btn layui-btn-danger " onclick="_getData(30)" type="button">最近30天</button>

        </form>
    </div>


    <div id="main" style="width: 99%;height:500px;"></div>

</div>


<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    var option = {
        title: {
            text: '网站访问明细'
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data:['访问量']
        },

        xAxis: {
            data: [],
            name:'日期',
        },
        yAxis: {
            name:'访问量 （单位次）',
        },
        series: [{
            name: '访问量',
            type: 'line',
            data: []
        },
            {
                name: '日常',
                type: 'line',
                data: []
            }
        ]
    };
    myChart.setOption(option);

    var _getData = function (type) {
        myChart.hideLoading();
        $.ajax({
            type: "POST",
            dataType: "json",
            url: '',
            data: {'token':'fasdfasdfadsf','type':type},
            success: function (res) {
                res = JSON.parse(res);
                myChart.setOption({
                    xAxis: {
                        data: res.data.days
                    },
                    series: [{
                        data: res.data.data
                    }]
                });
            }
        });
    };
    _getData(7);



</script>



</body>

</html>
